<?php $ui = $this->load->library('Ui'); ?>

    <h2>Blog Items</h2>
<?php

	$header = $ui->makeOption( anchor('blog/admin', 'Manage Blog') . ' '.
							   anchor('blog/admin/add_post', 'Add Blog Post'). ' ', 1 ).
							   '<div class="clear"></div>';

	$page_content = '<table cellspacing="1" cellpadding="5" width="100%"><tr class="head"><th width="13%">Title</th><th>Content</th><th width="13%">Actions</th></tr>';
	$limit = 225;
	$break = " ";
	foreach($items as $item)
	{
		$edit = base_url()."static/_css/images/icons/pencil.png";
		$delete = base_url()."static/_css/images/icons/delete.png";
		$activate = base_url()."static/_css/images/icons/accept.png";
		
		$id = $item['id'];
		$title = $item['title'];
		$pad = "...<br />";
		if(strlen($item['content']) >= $limit)
		{
			$breakpoint = strpos($item['content'], $break, $limit);
			$content = strip_tags( str_replace( "\n"," ", substr($item['content'], 0, $breakpoint) ) ) . $pad;
		}
		else
		{
			$content = strip_tags( str_replace( "\n"," ", $item['content'] ) );
		}	
		
			$page_content .= "<tr>
					<td valign='top'>".$title."</td>
					<td>".$content."</td>
					<td valign='top'>";
			if ( $id !== "" ){
			    $page_content .= anchor('blog/admin/edit_post/'.$id, "<img src='$edit' />")
				.anchor('blog/admin/delete_post/'.$id, "<img src='$delete' />");
			}
			$page_content .= "</td></tr>\n";
	}
	$page_content .= '</table>';
	
	echo $ui->makeDialog('Blog Items'.$header,$page_content,'maximize center');
?>
